package com.zhuidian.mothernote.fragment;

import android.app.Fragment;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.viewpager.widget.ViewPager;

import com.base.adapter.WrapperFragmentPagerAdapter;
import com.base.presenter.BasePresenter;
import com.google.android.material.tabs.TabLayout;
import com.zhuidian.mothernote.R;
import com.zhuidian.mothernote.global.BaseFragment;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class MineFragment extends BaseFragment {

    private ImageView iv_add_friend;
    private ImageView iv_setting;
    private RelativeLayout rl_wallet;
    private TextView tv_balance;
    private ImageView iv_arrow;
    private TabLayout tabLayout;
    private ViewPager viewPager;
    private TextView tv_fan;
    private TextView tv_attion;
    private TextView tv_get_like;
    private TextView tv_collect;
    private AnswerFragment answerFragment;
    private MineQuestionFragment mineQuestionFragment;
    private DraftFragment draftFragment;

    @Override
    protected int inflateMainLayoutId() {
        return R.layout.fragment_mine;
    }

    @Override
    protected void initView(View view) {
        iv_add_friend = (ImageView) view.findViewById(R.id.iv_add_friend);
        iv_setting = (ImageView) view.findViewById(R.id.iv_setting);
        rl_wallet = (RelativeLayout) view.findViewById(R.id.rl_wallet);
        tv_balance = (TextView) view.findViewById(R.id.tv_balance);
        iv_arrow = (ImageView) view.findViewById(R.id.iv_arrow);
        tabLayout = (TabLayout) view.findViewById(R.id.tabLayout);
        tv_fan = (TextView) view.findViewById(R.id.tv_fan);
        tv_attion = (TextView) view.findViewById(R.id.tv_attion);
        tv_get_like = (TextView) view.findViewById(R.id.tv_get_like);
        tv_collect = (TextView) view.findViewById(R.id.tv_collect);
        viewPager = (ViewPager) view.findViewById(R.id.viewPager);

        List titleList = Arrays.asList(getResources().getStringArray(R.array.mine_classification));
        tabLayout.addTab(tabLayout.newTab().setText((String) titleList.get(0)));
        tabLayout.addTab(tabLayout.newTab().setText((String) titleList.get(1)));
        tabLayout.addTab(tabLayout.newTab().setText((String) titleList.get(2)));
        ArrayList<Fragment> fragmentList = new ArrayList<>();
        answerFragment = new AnswerFragment();//回答
        mineQuestionFragment = new MineQuestionFragment();//提問
        draftFragment = new DraftFragment();//草稿
        fragmentList.add(answerFragment);
        fragmentList.add(mineQuestionFragment);
        fragmentList.add(draftFragment);
        WrapperFragmentPagerAdapter wrapperFragmentPagerAdapter = new WrapperFragmentPagerAdapter(getChildFragmentManager(), fragmentList);
        wrapperFragmentPagerAdapter.setPageTitleList(titleList);
        viewPager.setAdapter(wrapperFragmentPagerAdapter);
        viewPager.setOffscreenPageLimit(fragmentList.size());
        tabLayout.setupWithViewPager(viewPager);
        viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }

    @Override
    protected void setListener() {

    }

    @Override
    protected void initValue() {

    }

    @Override
    protected BasePresenter getPresenter() {
        return null;
    }

    @Override
    public void onClick(View view) {

    }
}
